/*===========================================
        
	MRS extractor
		
	Coders:	
		TalkLittle
		
	Credits:
		Jongware
		
============================================*/

#include <stdio.h>

#ifndef __MRS__
#define __MRS__

#define MRS_HEADER_LEN          780
#define MRS_CMAP_LEN            768
#define MRS_PALETTE_OFFSET      12

void Debug(const char * text);

typedef unsigned char MRSHEADER[MRS_HEADER_LEN];
/* Find the endianness of current machine */
int get_endianness();
void bswap_16(void *);
void bswap_32(void *);

/* Converting MRS to BMP */
void MRS_to_bmp_cmap(unsigned char *mrscmap, unsigned char *bmpcmap,
                     int nchannels, int colorsperchannel);
unsigned char *MRS_to_bmp_header(MRSHEADER mrsheader, unsigned int bmpsize,
                                 int *outheadersize);

/* MRS decompression */
void MRS_extract_single(FILE *infp, int width, int height, unsigned char *output);
unsigned char *MRS_extract_filename(FILE *infp, const char *filename,
                                    int16_t *width, int16_t *height,
                                    MRSHEADER mrsheader);

extern char *MRS_fileNames[];
extern long MRS_fileOffsets[];
extern int MRS_numFiles;

#endif
